import get from '@dfeidao/atom-web/local/get';
import remove from '@dfeidao/atom-web/local/remove';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
interface Aa {
	role_no: string;
}
import P01 from './P01';
import P04 from './P04';
import P05 from './P05';

export default async function a015(fd: IFeidaoAiBrowserComponent) {
	const productid = get(fd, 'productid');
	const role = get(fd, 'role') as Aa;
	const role_no = role.role_no;
	const page_no = get(fd, 'page_no') as number;
	const page_size = get(fd, 'page_size') as number;
	show_loading();
	const res = await nodejs<{ dataArray: object[], count: number, page_no: number, page_size: number }>('roler/service/pub_role_allot_find', { productid, role_no, page_no, page_size });
	hide_loading();
	if (res.count === 0) {
		render(fd, '', P01, 'P01', 'inner');
		render(fd, '', P04, 'P04', 'inner');
	} else {
		render(fd, res.dataArray, P01, 'P01', 'inner');
		res.page_no = page_no;
		res.page_size = page_size;
		render(fd, res, P05, 'P05', 'inner');
	}
	remove(fd, 'role_allot_id');
}
